package com.example.send.config;

import org.springframework.amqp.core.*;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

/**
 * 直接模式
 */
@Configuration
public class RabbitmqDirectConfig {

    public static final String DIRECT_EXCHANGE = "direct_exchange";

    public static final String DIRECT_QUEUE_1 = "direct_queue_1";
    public static final String DIRECT_QUEUE_2 = "direct_queue_2";

    @Bean
    public DirectExchange directExchange() {
        return new DirectExchange(DIRECT_EXCHANGE, true, false);
    }

    @Bean
    public Queue queueDirect1() {
        return new Queue(DIRECT_QUEUE_1, true, false, false);
    }

    @Bean
    public Queue queueDirect2() {
        return new Queue(DIRECT_QUEUE_2, true, false, false);
    }

    @Bean
    public Binding directBinding1() {
        return BindingBuilder.bind(queueDirect1()).to(directExchange()).with(queueDirect1().getName());
    }

    @Bean
    public Binding directBinding2() {
        return BindingBuilder.bind(queueDirect2()).to(directExchange()).with(queueDirect2().getName());
    }

}
